﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 第二次作业
{
    public partial class Trustcards : Form
    {
        TrustAccount trust = new TrustAccount();
        public Trustcards(TrustAccount trustAccount)
        {
            trust = trustAccount;
            InitializeComponent();
            label2.Text = trust.getId().ToString();
            label4.Text = trust.trustcredit.ToString();
            comboBox1.Items.Add("还款");
            comboBox1.Items.Add("取钱");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == 0)
            {
                trust.payback(double.Parse(textBox1.Text));
                label4.Text = trust.trustcredit.ToString();
            }
            if (comboBox1.SelectedIndex == 1)
            {
                BadCashException badCashException = new BadCashException();
                bool flag = badCashException.IsError();
                if (flag)
                {
                    MessageBox.Show("纸币有损坏,请重新操作");
                }
                else
                {
                    trust.withdrow(double.Parse(textBox1.Text));
                    label4.Text = trust.trustcredit.ToString();
                }
                
            }
        }
    }
}
